package com.example.t410.controller;

import com.example.t410.DTO.SportDTO;
import com.example.t410.VO.SportVO;
import com.example.t410.VO.SportVideoVO;
import com.example.t410.dao.NootbookResult;
import com.example.t410.service.SportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/sport")
@Slf4j
public class SportController {
    @Autowired
    SportService sportService;

    /**
     * 运动查询，名称，难度，时间
     * @param sportDTO
     * @return
     */
    @PostMapping
    public NootbookResult select(@RequestBody SportDTO sportDTO){
        log.info("运动查询，参数为：{}",sportDTO);
        List<SportVO> list=sportService.select(sportDTO);
        return NootbookResult.Success(list);
    }

    @GetMapping("/{id}")
    public NootbookResult selectById(@PathVariable Long id){
        log.info("查询运动信息的id为：{}",id);
        SportVideoVO sportVideoVO=sportService.selectById(id);
        return NootbookResult.Success(sportVideoVO);
    }

}
